<template>
	<!-- 顶部选项卡 -->
	<view class="uni-tab-bar">
		<scroll-view scroll-x="true" class="uni-swiper-tab">
			<block v-for="(tab,index) in tabBars" :key="tab.id">
				<view class="swiper-tab-list" :class="{'active':tabIndex==index}" @tap="tabtap(index)">
					{{tab.name}}
					<view class="swiper-tab-line"></view>
				</view>
			</block>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		props:{
			tabBars:Array,
			tabIndex:Number
		},
		methods:{
			//tabbar点击事件
			tabtap(index){
				//子组件向父组件传值
				this.$emit('tabtap',index) 
			},
		}
	}
</script>

<style scoped>
	.swiper-tab-list {
		color: #969696;
		font-weight: bold;
		/* 字体颜色加粗*/
	}
	
	.uni-tab-bar .active {
		color: #343434;
		/* 选中的字体颜色*/
	}
	
	.active .swiper-tab-line {
		border-bottom: 6upx solid #FEDE33;
		/* 选项下面的小黄条*/
		width: 80upx;
		margin: auto;
		border-top: 6upx solid #FEDE33;
		border-radius: 20upx;
	}
	
	.uni-swiper-tab {
		border-bottom: 1upx solid #EEEEEE;
		/* 水平线用浅颜色*/
	}
</style>
